chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
 if (request.action == "getDoubleClickTags")
   sendResponse({action: GetDoubleClickTags()});
 else if (request.action == "highlight")
   sendResponse({action: DoHighlightAd()});
 else if (request.action == "unhighlight")
   sendResponse({action: DoUnHighlightAd()});
 else
   sendResponse({action: 'invalid'}); // Send nothing..
});

function GetDoubleClickTags(){
	var elems=new Array();
	
	$.each($('script[src*=doubleclick]'),function(idx,elem) {
		var srcattr = elem.getAttribute('src');
		
		if ($.inArray(srcattr,elem) == -1)
			elems.push(srcattr );
	})
	
	return (elems);
}

function DoHighlightAd(){
	var ad='http://ad.uk.doubleclick.net/adj/primelocation.uk/EstateAgents;tile=2;pos=1;sz=728x90,468x60';
	$('script[src*=doubleclick]').parent().addClass( 'highlight' );
}

function DoUnHighlightAd(){
	var ad='http://ad.uk.doubleclick.net/adj/primelocation.uk/EstateAgents;tile=2;pos=1;sz=728x90,468x60';
	$('script[src*=doubleclick]').parent().removeClass( 'highlight' );
}